package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import com.itheima.pojo.OrderSettingDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PutMapping;

import java.util.Date;
import java.util.List;

@Mapper
public interface OrderSettingMapper {
    // 查询指定月份的预约设置数据
    @Select("SELECT * FROM t_ordersetting WHERE DATE_FORMAT(orderDate,'%Y-%m') = #{month}")
    List<OrderSetting> getOrderSettingByMonth(@Param("month")String month);
    void editNumberByOrderDate(OrderSettingDTO orderSettingDTO);
    // 根据预约日期查询预约设置数据
    @Select("SELECT * FROM t_ordersetting WHERE orderDate = #{orderDate}")
    OrderSetting findByOrderDate(Date orderDate);
    // 批量添加预约设置数据
    @Update("UPDATE t_ordersetting SET number = #{number} WHERE orderDate = #{orderDate}")
    void update(OrderSetting existing);
    // 批量添加预约设置数据
    @Insert("INSERT INTO t_ordersetting VALUES (#{id},#{orderDate},#{number},#{reservations})")
    void insert(OrderSetting setting);
}
